<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!doctype html>
<head>
	<meta charset="UTF-8"/>
	<title>后台管理系统</title>
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="shortcut icon" href="${pageContext.request.contextPath}/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/login/css/font.css">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/static/login/css/xadmin.css">
    <script src="${pageContext.request.contextPath}/static/js/jquery-1.11.0.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/xadmin.js"></script>
</head>
<body class="login-bg">

    <div class="login layui-anim layui-anim-up">
        <div class="message">后台管理系统登录</div>
        <div id="darkbannerwrap"></div>

        <form method="post" class="layui-form" >
            <input name="account" id="account" placeholder="用户名"  type="text" lay-verify="required" class="layui-input" >
            <hr class="hr15">
            <input name="password" id="password" lay-verify="required" placeholder="密码"  type="password" class="layui-input">
            <%--<hr class="hr15">
            <input name="imageCode" id="imageCode" lay-verify="required" placeholder="验证码"  type="text" style="width:69%;" onkeydown= "if(event.keyCode==13)form.submit()">
            <img onclick="loadimage();"  title="换一张试试" name="randImage" id="randImage" src="${pageContext.request.contextPath}/image.jsp" width="29%" height="45px" border="1" align="absmiddle">--%>
            <hr class="hr15">
            <input value="登录"  style="width:100%;" type="button" onclick="login();">
            <hr class="hr20" >
        </form>
    </div>

    <script>
    function login(){
         //layer.msg("加载中...");

         var account = $("#account").val();
         var password = $("#password").val();
         var imageCode = $("#imageCode").val();//JSON.stringify(e.field)
         if($.trim(account) == null || $.trim(account) ==""){
        	 layer.msg("账号不能为空!");
        	 return false;
         }
         if($.trim(password) == null || $.trim(password) ==""){
        	 layer.msg("密码不能为空!");
        	 return false;
         }
       /*  if($.trim(imageCode) == null || $.trim(imageCode) ==""){
        	 layer.msg("请输入验证码!");
        	 return false;
         }*/
         var index = layer.load();
         $.ajax({
             url:"${pageContext.request.contextPath}/submitLogin",
             // data:{"account":account,"password":password,"imageCode":imageCode,"rememberMe":false},
             data:{"account":account,"password":password,"rememberMe":false},
             type:"POST",
             dataType:"JSON",
             beforeSend:function(){
	        		layer.msg('开始登录...');
	        	},
             success:function(data){
            	 layer.close(index);
            	 if(data && data.status != 200){
		    		  layer.msg(data.message,function(){});
		    		  $("#password").val('');
		    		//  loadimage();
		    		  return;
		    	 }else{
		    		layer.msg(data.message);
		    		setTimeout(function(){
		    		//进入主页
			    	window.location.href= "${pageContext.request.contextPath}/index"},1000)
		    	 }
             },
             error:function(e){
                 console.log(e);
             }
         });
    }

    //更新验证码
    function loadimage(){
        document.getElementById("randImage").src="${pageContext.request.contextPath}/image.jsp?"+Math.random();
    }
    </script>
</body>
</html>